package com.service;

import java.util.ArrayList;
import java.util.List;

import com.bean.SelectItem;
import com.model.Syscode;

public class CodeService {
	public static final CodeService service = new CodeService();
	
	//获取代码编号的列表
	public List<SelectItem> getDmbhList(){
		List<SelectItem> itemList = new ArrayList<SelectItem>();
		List<Syscode> list = Syscode.dao.find("select distinct dmbh,dmmc from syscode ");
		for(Syscode code :list){
			itemList.add(new SelectItem(code.getDmbh(),code.getDmmc()));
		}
		return itemList;
	}
	public List<Syscode>  getSysCode(String dmbh){
		List<Syscode> list = Syscode.dao.find("select * from syscode where dmbh like ? order  by dmbh ",dmbh);
		return list;
	}
	
	public List<Syscode> getDmmcByDmbh(String dmbh){
		List<Syscode> list = Syscode.dao.find("select distinct dmmc from syscode where dmbh = ?" ,dmbh);
		return list;
	}
	public List<Syscode> getSyscodeBYDmbhAndCode(String dmbh, String code){
		List<Syscode> list = Syscode.dao.find("select distinct dmmc from syscode where dmbh = ? and code = ? " ,dmbh,code);
		return list;
	}
}
